/*
 * Copyright 2002-2012 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.aop;

/**
 * Interface supplying the information necessary to describe an introduction.
 *
 * <p>{@link IntroductionAdvisor IntroductionAdvisors} must implement this
 * interface. If an {@link org.aopalliance.aop.Advice} implements this,
 * it may be used as an introduction without an {@link IntroductionAdvisor}.
 * In this case, the advice is self-describing, providing not only the
 * necessary behavior, but describing the interfaces it introduces.
 *
 * @author Rod Johnson
 * @since 1.1.1
 */
/*
1. 总结
IntroductionInfo 是 Spring AOP 模块中的一个接口
用于描述 AOP 引入（Introduction）的相关信息
提供获取引入接口列表的方法
可以由 IntroductionAdvisor 或自描述的 Advice 实现
2. 内部成员解释
getInterfaces() 方法：
返回由此 Advisor 或 Advice 引入的额外接口数组
提供引入功能的接口描述信息
3. 相关的接口和类
IntroductionInfo (接口)
├── IntroductionAdvisor (子接口)
│   ├── DefaultIntroductionAdvisor (实现类)
│   │   ├── TimestampIntroductionAdvisor (实现类)
│   │   └── LockMixinAdvisor (实现类)
│   └── DeclareParentsAdvisor (实现类)
└── IntroductionInfoSupport (实现类)
    ├── DelegatingIntroductionInterceptor (实现类)
    │   ├── LockMixin (实现类)
    │   └── TimestampIntroductionInterceptor (实现类)
    └── DelegatePerTargetObjectIntroductionInterceptor (实现类)

关系说明
IntroductionInfo：顶层接口，定义了获取引入接口的方法
IntroductionAdvisor：IntroductionInfo 的子接口，扩展了引入顾问的功能
IntroductionInfoSupport：抽象支持类，实现了 IntroductionInfo 接口
DefaultIntroductionAdvisor：默认的引入顾问实现，可以包装任何实现了 IntroductionInfo 的对象
DeclareParentsAdvisor：实现了声明式父类功能，允许在运行时为对象添加新的接口实现
DelegatingIntroductionInterceptor：通过委托机制实现引入功能，将方法调用转发给目标对象
DelegatePerTargetObjectIntroductionInterceptor：为每个目标对象提供独立的引入拦截器实例
LockMixin 和 TimestampIntroductionInterceptor：具体的引入拦截器实现，分别用于锁定功能和时间戳功能


4使用场景
	AOP 引入功能：向现有类动态添加新的接口实现
	混入（Mixin）模式：为多个类添加通用功能
	动态代理增强：在运行时扩展对象的功能
	声明式父类：通过配置而非代码修改来添加新功能

5 实际代码应用示例
	// 1. 定义要引入的接口
public interface Lockable {
    void lock();
    void unlock();
    boolean locked();
}

// 2. 创建引入拦截器
public class LockMixin extends DelegatingIntroductionInterceptor implements Lockable {

    private boolean locked;

    @Override
    public void lock() {
        this.locked = true;
    }

    @Override
    public void unlock() {
        this.locked = false;
    }

    @Override
    public boolean locked() {
        return this.locked;
    }

    // 重写 invoke 方法来控制访问
    @Override
    public Object invoke(MethodInvocation invocation) throws Throwable {
        if (locked() && invocation.getMethod().getName().indexOf("set") == 0) {
            throw new IllegalStateException("Locked object cannot be modified");
        }
        return super.invoke(invocation);
    }
}

// 3. 创建引入顾问
IntroductionAdvisor advisor = new DefaultIntroductionAdvisor(new LockMixin());

// 4. 应用于代理工厂
ProxyFactory proxyFactory = new ProxyFactory(targetObject);
proxyFactory.addAdvisor(advisor);

// 5. 获取代理对象并使用
Object proxy = proxyFactory.getProxy();
Lockable lockable = (Lockable) proxy;
lockable.lock();


 */
public interface IntroductionInfo {

	/**
	 * Return the additional interfaces introduced by this Advisor or Advice.
	 * @return the introduced interfaces
	 */
	Class<?>[] getInterfaces();

}
